/*
 * @Author: humengchuan 531537052@qq.com
 * @Date: 2024-09-11 14:41:26
 * @LastEditors: humengchuan 531537052@qq.com
 * @LastEditTime: 2024-09-11 16:46:30
 * @FilePath: \projecte:\学习\react\my-react-frameworke\src\components\Button\button.tsx
 * @Description: 
 */
import React from 'react'
import classNames from 'classnames';

export enum buttonSize {
    Large = 'lg',
    Small = 'sm',
}
export enum buttonType {
    Primary = 'primary',
    Default = 'default',
    Danger = 'danger',
    Link = 'link'
}
interface BaseProps {
    type?: buttonType;
    className?: string;
    size?: buttonSize;
    disabled?: boolean;
    href?: string;
    children: React.ReactNode;
}

const Button: React.FC<BaseProps> = (props) => {
    const { type, className, size, href, disabled, children } = props;
    const classes = classNames('btn', className, {
        [`btn-${type}`]: type,
        [`btn-${size}`]: size,
        disabled
    })
    if (type === buttonType.Link && href) {
        return <a className={classes} href={href}>{children}</a>
    } else {
        return <button className={classes} disabled={disabled}>{children}</button>
    }
}


export default Button